#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "I2C_Hard.h"
#include "OLED_I2C_HARD.h"
#include "stdio.h"
#include "Mpu6050_I2C_HARD.h"
#include "Uart.h"
#include "DMA_UART1.h"
#include "Timer.h"
#include "Mpu6050_DMP.h"
#include "RTC_Timer.h"
#include <stdio.h>
#include "log.h"

static mpu6050_data * mpu6050_raw_data;

int main(void)
{
    // 配置 NVIC 中段优先级
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    
        
    init_dma_for_uart1();
    
    init_uart_with_dma();
    
    
   timer_init();
   //init_RTC_timer();
    
   init_i2c();
	init_oled();
   init_mpu_6050();
    
    show_string(0,1,"abc");
    
    printf("1.hello\n");
    MPL_LOGE("2.luojunhua\n");
    
   init_mpu6050_with_dmp();
    

    printf("3.dmp initialized\n");
 
  
    char str[50];
    
    //Integrated_Euler_Angles  integrated_euler_angles;
    
    float pitch, roll,yaw;
    
    
	while (1)
	{
        
        mpu_dmp_get_data(&pitch,&roll,&yaw);
        
        sprintf(str,"%7f",roll);
		show_string(1,1,(uint8_t *)str);
        
        sprintf(str,"%7f",pitch);
		show_string(2,1,(uint8_t *)str);
        
        sprintf(str,"%7f",yaw);
		show_string(3,1,(uint8_t *)str);
        
        printf("%7f,%7f,%7f\n",roll,pitch,yaw);
        //send((uint8_t *)str,sizeof(str));
  
    }
}



int fputc(int ch, FILE* stream)
{
	USART_SendData(USART1, (unsigned char) ch);
	while (!(USART1->SR & USART_FLAG_TXE));
	//send((uint8_t*)&ch,1);
	return ch;
}

/*
int fput(int file, char *ptr, int len)
{
    send((uint8_t *)ptr, len); 
    
    return len;
}
*/


